
************************
***********************
*
*	Replication Do File for: 
*
*	  
*	Hawes, Daniel P., and Austin M. McCrea. 2017. 
*	"Give Us Your Tired, Your Poor and We Might Buy Them Dinner: 
*	Social Capital, Immigration and Welfare Generosity in the American States." 
*	Political Research Quarterly
* 
*	Daniel P. Hawes - Kent State University 
*		and
*	Austin M. McCrea - Texas A&M University
*
*	Models were run using Stata 13.1
* 	
************************
************************

use "PATH...\Hawes&McCrea_PRQ_ReplicationData.dta"

xtset fips year


* TABLE 1
sum tanf_scpi  SC86 pctfb_ma  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk   if e(sample)

* TABLE 2
  
* Model 1
xtpcse tanf_scpi  SC86 pctfb_ma  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  i.year i.fips
* Model 2
xtpcse tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  i.year i.fips

* FIGURE 1
* Interaction - Marginal Effects

sort fips year

discard
capture program drop bgc_equ2
program define bgc_equ2
syntax varname(numeric max=1 ts), modx2(varname max=1) inter(varname max=1) 
capture drop mode inter
gen x2 = `modx2'
gen inter = `inter'

matrix b=e(b)
matrix V=e(V)
scalar b1=b[1,1]
scalar b2=b[1,2]
scalar b3=b[1,3] 
scalar varb1=V[1,1]
scalar varb2=V[2,2] 
scalar varb3=V[3,3]
scalar covb1b3=V[1,3] 
scalar covb2b3=V[2,3]

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3 
gen conb1=b1 + b3*x2
gen conseb1=sqrt(varb1+varb3*(x2^2)+ 2*covb1b3*x2)
gen a=1.96*conseb1
gen upper=conb1+a
gen lower=conb1-a
gen tratio = conb1/conseb1
sum x2-tratio if e(sample)

graph twoway line conb1 x2, clwidth(medium) clcolor(blue) clcolor(black) /*
*/ || lowess upper x2, clpattern(dash) clwidth(thin) clcolor(black) /*
*/ || lowess lower x2, clpattern(dash) clwidth(thin) clcolor(black) /*
*/ || kdensity x2, yaxis(2) fintensity(10) lwidth(vvthin) /*
*/ || , /*
*/ legend(col(1) order(1 2 4) label(1 "Marginal Effect of `1' ") /*
*/ label(2 "95% Confidence Interval") /*
*/ label(3 "Density of `x2'")) /*
*/ yline(0, lcolor(black)) /*
*/ xtitle("`x2'", size(3) ) /*
*/ xsca(titlegap(2)) /*
*/ ysca(titlegap(2)) /*
*/ ytitle("Marginal Effect (b) of Social Capital ", size(3)) 

end


xtpcse tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  i.year i.fips
bgc_equ2 SC8609_ma, modx2(pctfb_ma) inter(SC_pFB)



***APPENDIX

*M1 - RE, robust
xtreg tanf_scpi  SC86 pctfb_ma tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  , robust 
*M2 - RE, robust - Interaction
xtreg tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  , robust 
*M3 - FE (FIPS)
xtreg tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk , fe  
*M4 - 2-way FE
xtreg tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk i.year, fe  
**M5 - PCSE with Lagged DV 
xtpcse tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk l.tanf_scpi  
*M6 - 2-Way FE with LDV, PCSE
xtpcse tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  l.tanf_scpi i.year i.fips
*M7 - 2-Way FE, PCSE AR(1)
xtpcse tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  i.year i.fips, corr(ar1)
*M8 - 2-Way FE, PCSE PSAR(1)
xtpcse tanf_scpi  SC86 pctfb_ma SC_pFB  tanfcaseloadK avgnbrtanf unmarried_birth pov_rtfull cit_ideology  totdempct hvd_4yr  women_leg unemp adj_GSPpcK adj_incpcK pcturban_MA high_school pop_pcthisp pop_pctblk  i.year i.fips, corr(psar1)





